<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>智能订餐</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/base/Inforschool/css/style.css">
    <link rel="stylesheet" href="/assets/base/Inforschool/css/layer.css">
</head>
<body>
<div class="wraper">
    <div class="header font-white">
        <a href="javascript:history.go(-1)" class="iconfont icon-left font-white back"></a>
        <div class="font-16 text-center">添加人员</div>
    </div>
    <div class="bg_white padding-12 margin-12">
        <div class="boxs padding-0 border">
            <input id="ycname" type="text" placeholder="请输入姓名" class="font-gray2 add_input">
        </div>
        <div class="boxs padding-0 border">
            <input id="ymobile" type="text" placeholder="请输入手机号码" class="font-gray2 add_input">
        </div>

        <input id="ftype" type="hidden" name="ftype" class="font-gray2 add_input" value="{BEESCRM:$ftype}">

        <div class="boxs padding-0 border flex_between">
            <select id="type" class="add_input font-gray2">
                <option value="0">请选择身份</option>
                <if condition="$ftype eq 1">
                    <option value="1">学生</option>
                    <option value="2">教职工</option>
                </if>
                <if condition="$ftype neq 1">
                    <option value="3">来宾</option>
                </if>
            </select>
            <div class="iconfont icon-xiala font-gray2"></div>
        </div>
        <div class="boxs padding-0 border">
            <input id="remark" type="text" placeholder="备注" class="font-gray2 add_input">
        </div>
    </div>
    <a href="#" class="btn btn_save font-16 text-center">保存</a>
</div>
</body>
<script src="/assets/base/Inforschool/js/jquery-2.1.0.min.js"></script>
<script src="/assets/base/Inforschool/js/layer.js"></script>
<script src="/assets/base/Inforschool/js/public.js"></script>
<script>
    $('.btn').click(function () {
        var name = $('#ycname').val();
        var mobile = $('#ymobile').val();
        var type = $('#type').val();
        var ftype = $('#ftype').val();
        var remark = $('#remark').val();
        if (!name) {
            fm.alert('请填写姓名');
            return false;
        }
        if (!mobile) {
            fm.alert('请填手机号码');
            return false;
        }
        if (!(/^1[34578]\d{9}$/.test(mobile))) {
            fm.alert('请输入正确的手机号码');
            return false;
        }
        if (type == 0) {
            fm.alert('请选择类型');
            return false;
        }
        var info = {};
        info.name = name;
        info.ftype = ftype;
        info.mobile = mobile;
        info.type = type;
        info.remark = remark;
        $.ajax({
            'url': "/base/Inforschool/addPeople",
            'data': info,
            'dataType': 'json',
            'type': 'POST',
            success: function (result) {
                if (result.status == 'S') {
                    setTimeout("reload('"+result.url+"')", 2000);
                    fm.alert(result.message);
                } else if (result.status == 'F') {
                    fm.alert(result.message);
                    reload1();
                }
            }
        })
    });
    function reload1() {
        setTimeout('location.reload()', 3000);
    }
    function reload(url) {
        window.location.href = url;
    }
</script>
</html>